<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>三层盒子嵌套</title>
    <style>
        .wrap {
            width: 200px;
            height: 200px;
            margin: 100px auto;
            position: relative;
            transform-style: preserve-3d;
            transform: rotateX(0deg) rotateY(0deg);
        }

        .box {
            width: 200px;
            height: 200px;
            font-size: 50px;
            font-weight: 700;
            text-align: center;
            line-height: 200px;
            position: absolute;
            left: 0;
            top: 0;
            opacity: 0.5;
        }

        .box1 {
            background-color: darkred;
            transform: rotateY(180deg);
        }

        .box2 {
            background-color: darkorange;
            transform-origin: top;
            transform: rotateX(90deg);
        }

        .box3 {
            background-color: darkgoldenrod;
            transform-origin: right;
            transform: rotateY(90deg);
        }

        .box4 {
            background-color: darkgreen;
            transform-origin: bottom;
            transform: rotateX(-90deg);
        }

        .box5 {
            background-color: teal;

            transform-origin: left;
            transform: rotateY(-90deg);
        }

        .box6 {
            background-color: darkmagenta;
            transform: translateZ(200px);
        }

        .inner {
            width: 100px;
            height: 100px;
            position: absolute;
            top: 50px;
            left: 50px;
            opacity: 0.3;
        }

        .inner>img {
            width: 100%;
            height: 100%;
        }

        .inner1 {
            transform: translateZ(50px);
        }

        .inner2 {
            transform-origin: top;
            transform: translateZ(50px) rotateX(90deg);
        }

        .inner3 {
            transform-origin: right;
            transform: translateZ(50px) rotateY(90deg);
        }

        .inner4 {
            transform-origin: bottom;
            transform: translateZ(50px) rotateX(-90deg);
        }

        .inner5 {
            transform-origin: left;
            transform: translateZ(50px) rotateY(-90deg);
        }

        .inner6 {
            transform: translateZ(150px);
        }

        .text {
            width: 50px;
            height: 50px;
            position: absolute;
            top: 75px;
            left: 75px;
        }

        .text>img {
            width: 100%;
            height: 100%;
        }

        .text1 {
            transform: translateZ(125px);
        }

        .text2 {
            transform-origin: top;
            transform: translateZ(75px) rotateX(90deg);
        }

        .text3 {
            transform-origin: right;
            transform: translateZ(75px) rotateY(90deg);
        }

        .text4 {
            transform-origin: bottom;
            transform: translateZ(75px) rotateX(-90deg);
        }

        .text5 {
            transform-origin: left;
            transform: translateZ(75px) rotateY(-90deg);
        }

        .text6 {
            transform: translateZ(75px);
        }

        .wrap:hover .box1 {
            transform: translateZ(-200px);
        }
    </style>
</head>

<body>
    <div class="wrap">
        <div class="box box1">1</div>
        <div class="box box2">2</div>
        <div class="box box3">3</div>
        <div class="box box4">4</div>
        <div class="box box5">5</div>
        <div class="box box6">6</div>
        <div class="inner inner1"><img src="./images/1.jpg" alt=""></div>
        <div class="inner inner2"><img src="./images/1.jpg" alt=""></div>
        <div class="inner inner3"><img src="./images/1.jpg" alt=""></div>
        <div class="inner inner4"><img src="./images/1.jpg" alt=""></div>
        <div class="inner inner5"><img src="./images/1.jpg" alt=""></div>
        <div class="inner inner6"><img src="./images/1.jpg" alt=""></div>
        <div class="text text1"><img src="./images/2.jpg" alt=""></div>
        <div class="text text2"><img src="./images/2.jpg" alt=""></div>
        <div class="text text3"><img src="./images/2.jpg" alt=""></div>
        <div class="text text4"><img src="./images/2.jpg" alt=""></div>
        <div class="text text5"><img src="./images/2.jpg" alt=""></div>
        <div class="text text6"><img src="./images/2.jpg" alt=""></div>
    </div>
</body>

</html>